package com.clinic.accessor.db;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import com.clinic.entity.db.Syptom;
import com.clinic.entity.param.Index;

@Component
public class SyptomAccessor extends AbstractDbAccessor<Syptom>{
	
	public Syptom getSyptomById(long id) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Syptom.class);
		criteria.add(Restrictions.eq(Syptom.Columns.SYPTOM_ID, id));
		return uniqueGeneric(criteria);
	}
	
	public Syptom getSyptomByName(String name) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Syptom.class);
		criteria.add(Restrictions.eq(Syptom.Columns.NAME, name));
		return uniqueGeneric(criteria);
	}
	
	public List<Syptom> getSyptoms(Index index) {
		DetachedCriteria criteria = DetachedCriteria.forClass(Syptom.class);
		return listGeneric(criteria, index);
	}
}
